<!--
 * @Author      : 徐博
 * @Date        : 2024-06-07 13:51:26
 * @LastEditTime: 2024-06-07 13:51:26
 * @LastEditors : 徐博
 * @FilePath    : /Users/xubo/study/vue3/vue3-ts-vite/src/views/index/components/memus.vue
 * @Description : desc
 */
 -->
<template>
    <fe-menu :menus="menuList"></fe-menu>
</template>

<script setup lang="ts">
import FeMenu from '@/components/fe-menu/fe-menu.vue';
import { menus } from '../menus.data';
import {GlobalState} from "@/store";
import {ref} from "vue";


const store = GlobalState();

const filterArr = (arr: any[]) => {
  return arr.filter((item)=>{
    if(item.children && item.children.length > 0) {
      item.children =  filterArr(item.children)
    }
    return store.userInfo.permissions_menu?.includes(item.url)
  })
}

const menuList = ref<any[]>()
menuList.value = filterArr(menus);
</script>
